import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 引入一级路由
let login=()=> import("../pages/login/login.vue");
let index=()=> import("../pages/index/index.vue");
let list=()=> import("../pages/list/list.vue");
let search=()=> import("../pages/search/search.vue");
let register=()=> import("../pages/register/register.vue");
let detail=()=> import("../pages/detail/detail.vue");
let orders=()=> import("../pages/orders/orders.vue");
let address=()=> import("../pages/address/address.vue");
let addressAdd=()=> import("../pages/addressAdd/addressAdd.vue");
let payment=()=> import("../pages/payment/payment.vue");

// 引入二级路由
let home=()=> import("../pages/home/home.vue");
let cate=()=> import("../pages/cate/cate.vue");
let shop=()=> import("../pages/shop/shop.vue");
let mine=()=> import("../pages/mine/mine.vue");


const routes = [

  {
    path:"/index",
    component:index,
    meta:{
      title:"首页"
    },
    children:[
      {
        path:"home",
        component:home,
        meta:{
          title:"首页"
        },
      },
      {
        path:"cate",
        component:cate,
        meta:{
          title:"分类"
        },
      },
      {
        path:"shop",
        component:shop,
        meta:{
          title:"购物车"
        },
      },
      {
        path:"mine",
        component:mine,
        meta:{
          title:"个人中心"
        },
      },
      {
        path:"",
        redirect:"home"
      }
    ]
  },
  {
    path:"/login",
    component:login,
    meta:{
      title:"手机登录"
    },
  },
  {
    path:"/list",
    component:list,
    meta:{
      title:"列表"
    },
  },
  {
    path:"/search",
    component:search,
    meta:{
      title:"搜索"
    },
  },
  {
    path:"/register",
    component:register,
    meta:{
      title:"注册"
    },
  },
  {
    path:"/detail/:id",
    component:detail,
    meta:{
      title:"详情"
    },
  },
  {
    path:"/orders",
    component:orders,
    meta:{
      title:"确认订单"
    },
  },
  {
    path:"/address",
    component:address,
    meta:{
      title:"地址管理"
    },
  },
  {
    path:"/addressAdd",
    component:addressAdd,
    meta:{
      title:"新增地址"
    },
  },
  {
    path:"/payment",
    component:payment,
    meta:{
      title:"支付页面"
    },
  },
  {
    path:"*",
    redirect:"index"
  }


]

const router = new VueRouter({
  routes
})

export default router
